const HMTT = "hmtt";
// 1. 存储 token
export const setItem = (token) => localStorage.setItem(HMTT, token);
// 2. 获取 token
export const getItem = () => localStorage.getItem(HMTT);
// 3. 删除 token
export const removeItem = () => localStorage.removeItem(HMTT);

// 存储关注栏目数据
const HMTT_FOLLOW_CATE = "HMTT_FOLLOW_CATE";
// 1. 存储 cate
export const setCate = (cate) =>
  localStorage.setItem(HMTT_FOLLOW_CATE, JSON.stringify(cate));
// 2. 获取 cate
export const getCate = () =>
  JSON.parse(localStorage.getItem(HMTT_FOLLOW_CATE)) || [];
// 3. 删除 cate
export const removeCate = () => localStorage.removeItem(HMTT_FOLLOW_CATE);

// 存储未关注栏目数据
const HMTT_UNFOLLOW_CATE = "HMTT_UNFOLLOW_CATE";
// 1. 存储 unCate
export const setUnCate = (unCate) =>
  localStorage.setItem(HMTT_UNFOLLOW_CATE, JSON.stringify(unCate));
// 2. 获取 unCate
export const getUnCate = () =>
  JSON.parse(localStorage.getItem(HMTT_UNFOLLOW_CATE)) || [];
// 3. 删除 unCate
export const removeUnCate = () => localStorage.removeItem(HMTT_UNFOLLOW_CATE);

// 存储用户id
const HMTT_USER_ID = "HMTT_USER_ID";
export const setUserId = (user_id) =>
  localStorage.setItem(HMTT_USER_ID, user_id);
export const getUserId = () => localStorage.getItem(HMTT_USER_ID);
export const removeUserId = () => localStorage.removeItem(HMTT_USER_ID);

// 搜索历史 - 多个
const HMTT_SEARCH_KEYWORD = "HMTT_SEARCH_KEYWORD";
export const setSearchKeyword = (val) =>
  localStorage.setItem(HMTT_SEARCH_KEYWORD, JSON.stringify(val));
export const getSearchKeyword = () =>
  JSON.parse(localStorage.getItem(HMTT_SEARCH_KEYWORD)) || [];
export const removeSearchKeyword = () =>
  localStorage.removeItem(HMTT_SEARCH_KEYWORD);
